package com.tanguy.user.ui.map.activity

import android.annotation.SuppressLint
import android.os.Bundle
import com.amap.api.maps.MapView
import com.tanguy.user.R
import com.tanguy.user.base.ImmersionTitleActivity
import org.jetbrains.anko.find


/**
 * Created by dab on 2017/11/15 0015 16:02
 */
abstract class BaseMapActivity : ImmersionTitleActivity() {
     val mMapView : MapView by lazy {
         find<MapView>(R.id.map)
     }
    val aMap by lazy {
        mMapView.map
    }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        mMapView.onCreate(savedInstanceState)
    }

    override fun onDestroy() {
        super.onDestroy()
        //在activity执行onDestroy时执行mMapView.onDestroy()，销毁地图
        mMapView.onDestroy()
    }

    @SuppressLint("MissingSuperCall")
    override fun onResume() {
        super.onResume()
        //在activity执行onResume时执行mMapView.onResume ()，重新绘制加载地图
        mMapView.onResume()
    }

    @SuppressLint("MissingSuperCall")
    override fun onPause() {
        super.onPause()
        //在activity执行onPause时执行mMapView.onPause ()，暂停地图的绘制
        mMapView.onPause()
    }

    @SuppressLint("MissingSuperCall")
    override fun onSaveInstanceState(outState: Bundle?) {
        super.onSaveInstanceState(outState)
        //在activity执行onSaveInstanceState时执行mMapView.onSaveInstanceState (outState)，保存地图当前的状态
        mMapView.onSaveInstanceState(outState)
    }
}